from fastapi import APIRouter, Form, File, UploadFile
from typing import List

# pip install python-multipart
app5 = APIRouter()


@app5.post("/file")
async def get_file(file: bytes = File()):
    # file接收字节流数据，适合小文件，直接到用户内存
    return {
        "file": len(file)
    }


@app5.post("/files")
async def get_files(files: List[bytes] = File()):
    # file接收字节流数据，适合小文件，直接到用户内存
    return {
        "files": len(files)
    }


@app5.post("/uploadFile")
async def upload_file(file: UploadFile):
    print("file", file)
    return {
        "file": file.filename
    }
